package file;

import java.io.File;

public class ListFilesDemo3 {
    public static void main(String[] args) {

        File file=new File(".");
        if(file.isDirectory()){

            File[] files=file.listFiles( pathname->pathname.getName().endsWith(".txt"));
            for(File sub:files){
                System.out.println(sub.getName());
            }


        }
    }
}
